Sub Wait4Rez 
/if (${Window[RespawnWnd].Open} || ${SpawnCount[PC ${Me.Name}]}<1) {
	:waitforzoned
	/if (${Window[RespawnWnd].Open}) /notify RespawnWnd RW_SelectButton leftmouseup
	/delay 3s ${SpawnCount[PC ${Me.Name}]}>1
	/if (${SpawnCount[PC ${Me.Name}]}<1) /goto :waitforzoned
}
:waitforrez 
/if (!${Window[ConfirmationDialogBox].Open} && !${Window[RespawnWnd].Open} && ((${SpawnCount[${Me}'s corpse]}>0 && ${NearestSpawn[${Me}'s corpse].Distance}>100) || ${SpawnCount[${Me}'s corpse]}<1)) { 
	/delay 5s ${Window[ConfirmationDialogBox].Open} 
	/goto :waitforrez 
} 
/if (${Window[ConfirmationDialogBox].Open}) {
	/delay 8
	/notify ConfirmationDialogBox Yes_Button  leftmouseup 
}
:zonein 
/delay 5 
/squelch /target mycorpse 
/delay 5 
/if (${Target.CleanName.NotEqual[${Me}'s corpse]}) /goto :zonein 
/if (${Target.CleanName.Equal[${Me}'s corpse]}) { 
	/delay 3s 
	/call Loot_Corpse 
} else /goto :zonein 
/return 

| #################  Looting Corpse 

Sub Loot_Corpse 
/declare LootTotal int local 0 
/declare LootSlot int local 
/squelch /target mycorpse 
/if (${Target.Type.NotEqual[CORPSE]} || !${Target.ID}) { 
	/echo ** Can't target my corpse. 
	/return 
}    
/if (${Target.Type.Equal[CORPSE]} && ${Target.ID} && ${Target.Distance}>10 && ${Target.Distance}<100) {
	/corpsedrag 
	/delay 5
	/corpsedrop
}
/delay 1s 
/loot 
/delay 1s 
/if (${Me.State.NotEqual[BIND]}) { 
	/echo ** Massive lag right now... Aborting looting. 
	/return 
} 
:LootLag 
/if (${LootTotal}!=${Corpse.Items}) { 
	/varset LootTotal ${Corpse.Items} 
	/delay 5 
	/goto :LootLag 
} 
/for LootSlot 1 to ${LootTotal} 
	:LootItem 
	/itemnotify loot${LootSlot} rightmouseup 
	/delay 3 
	/if (${Corpse.Item[${LootSlot}].ID}) { 
		/delay 2 
		/goto :LootItem 
	} 
/next LootSlot 
/delay 5 
/echo ** Done looting my corpse. 
/notify LootWnd DoneButton leftmouseup 
/return 
